# -*- coding: utf-8 -*-

# Scrapy settings for zhaobiao project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     https://docs.scrapy.org/en/latest/topics/settings.html
#     https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
#     https://docs.scrapy.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'zhaobiao'

SPIDER_MODULES = ['zhaobiao.spiders']
NEWSPIDER_MODULE = 'zhaobiao.spiders'

# Crawl responsibly by identifying yourself (and your website) on the user-agent
# USER_AGENT = 'zhaobiao (+http://www.yourdomain.com)'

# Obey robots.txt rules
ROBOTSTXT_OBEY = False

# Configure maximum concurrent requests performed by Scrapy (default: 16)
# CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
DOWNLOAD_DELAY = 5
# The download delay setting will honor only one of:
# CONCURRENT_REQUESTS_PER_DOMAIN = 16
# CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
# COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
# TELNETCONSOLE_ENABLED = False

# Override the default request headers:
DEFAULT_REQUEST_HEADERS = {
    # 必联网请求头
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36',
    'Cookie': '__cfduid=d90681fda2d95c97e6923384dc63552af1567056142; Hm_lvt_ce4aeec804d7f7ce44e7dd43acce88db=1567056144; JSESSIONID=846DB79B5474546CF888D5C6CB96A7BB; Hm_lpvt_ce4aeec804d7f7ce44e7dd43acce88db=1567056227',
    # 剑鱼网请求头
    # 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36',
    # 'Cookie': 'SESSIONID=1dafc4b9ac4061d88cf5da818b609ba703c024ff; UM_distinctid=16cdd82d275614-0d4c8d437a7ca3-7373e61-1fa400-16cdd82d276899; selectNum=1; CNZZDATA1261815924=1061752773-1567084434-https%253A%252F%252Fwww.google.com%252F%7C1567089699; Hm_lvt_72331746d85dcac3dac65202d103e5d9=1567084434,1567090121; Hm_lpvt_72331746d85dcac3dac65202d103e5d9=1567090410; userid_secure=RrzwS0/MCgbMmKpU9HROGbMCaIIKQPckUwQUqV8rs+wNddxYryB0Q8cn66rhEvwov+UzNzBUpfcqAGRUjC7WZChgy4n6vhzSTwWTsCNnpW0QYi5WWWF4SEMHlZh7///PR1mfs+7EHq59P+Xxh3gAV1us6zBI0RuS3WgeqECh4f7I2KRN+BiiwY/T1qj3ROFIu5LIfbHO/YUsJeNWrs60TNxUS5t2dcF5B62MCr8EuaSGZQGf+OTOv3uy25ZKJUK6AxksSVywywGWIfIA8WawXiAXOuOz4BnZHEEtq7NcNC1MnoBi7cl6FZC4REBuYKdFs72djIXxAUlP7nDtpeRhyCoqKjIwMTktMDgtMjUgMDA6MDA6MDA=',
}

# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
# SPIDER_MIDDLEWARES = {
#    'zhaobiao.middlewares.ZhaobiaoSpiderMiddleware': 543,
# }

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    'zhaobiao.middlewares.ZhaobiaoDownloaderMiddleware': 543,
}

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
# EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
# }

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
    'zhaobiao.pipelines.ZhaobiaoPipeline': 300,
}

# Enable and configure the AutoThrottle extension (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/autothrottle.html
# AUTOTHROTTLE_ENABLED = True
# The initial download delay
# AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
# AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
# AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
# AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
# HTTPCACHE_ENABLED = True
# HTTPCACHE_EXPIRATION_SECS = 0
# HTTPCACHE_DIR = 'httpcache'
# HTTPCACHE_IGNORE_HTTP_CODES = []
# HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'

LOG_FILE = 'zhaobiao.log'
LOG_LEVEL = 'ERROR'

# 启动Scrapy-Redis去重过滤器，取消Scrapy的去重功能
DUPEFILTER_CLASS = "scrapy_redis.dupefilter.RFPDupeFilter"
# 启用Scrapy-Redis的调度器，取消Scrapy的调度器
SCHEDULER = "scrapy_redis.scheduler.Scheduler"
# Scrapy-Redis断点续爬
SCHEDULER_PERSIST = True
# 配置Redis数据库的连接
REDIS_URL = 'redis://127.0.0.1:6379'


